﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FDFtpSync.Entities
{
    /*
     * CreatedOn: 2018-05-23
     * CreatedBy: Jackie Lee(天宇遊龍)
     */
    /// <summary>
    /// 结果
    /// </summary>
    public class ApiResult
    {
        /// <summary>
        /// 0为成功
        /// </summary>
        public int Code { get; set; }

        public string Message { get; set; }

        public static ApiResult Faliure(string message, int code=100)
        {
            return new ApiResult
            {
                Code = code,
                Message = message
            };
        }
    }

    public class ApiResult<T> : ApiResult
    {
        public T Result { get; set; }

        public static ApiResult<T> Success(T result, string message = "OK")
        {
            return new ApiResult<T>
            {
                Code = 0,
                Result = result,
                Message = message
            };
        }
    }
}
